'use strict';window.FN||(()=>{function u(a,g){let e=b=>{b&&void 0!==b.error&&(console.error("AutoControl script:",b.error),b.error instanceof Error&&(b.error+=""));g(b)},c=!0;if(a.pongId)r[a.pongId](a.result),delete r[a.pongId];else if(a.event)if(a.event.delete)delete window[a.funcName];else{var d=window[a.funcName];d&&d(a.event)}else if(a.scriptId)try{c=B(C(a.scriptId,a.tabId,a.targetTabs,a.trigInstId)(),a.funcCode,a.args);if(c instanceof Promise)return c.then(b=>e({result:b}),b=>e({error:b})),!0;
c={result:c}}catch(b){c={error:b}}else if(a.funcCode){if(c=FN(a.funcCode)(...a.args),"function"==typeof c)return c(e),!0}else if(null!=a.insertCode)d=document.createElement("js"==a.type?"script":"style"),d.textContent=a.insertCode,document.head.appendChild(d);else if(a.scrtCtxVar)void 0===a.value?c=x[a.scrtCtxVar]:x[a.scrtCtxVar]=a.value;else return;e(c)}function v(a,g){if(y){for(var e=1;e in r;++e);r[e]=g;a.pingId=e;parent.postMessage(a,"*")}else m.runtime.sendMessage(a,c=>{var d=m.runtime.lastError;
return g(d?{error:d}:c)})}function C(a,g,e,c){return function w(...b){return new Proxy(()=>{},{get(n,p){if("__proto__"==p)return n[p];if(!b.length)switch(p){case "TAB_ID":return g;case "STOP_CHAIN":return Object.freeze({break:"inner"});case "STOP_FULL_SEQ":return Object.freeze({break:"outer"})}return w(...b,p)},apply(n,p,f){if("function"==typeof f[0]&&"then"==b[b.length-1]){var z=f;f=[];b.pop()}n=new Promise((D,A)=>{if("saveFile"==b[0]){var k="_"+(Math.random()+"").slice(2);window[k]=f[1];f[1]=k}else if("setClipboard"==
b[0])k="_"+(Math.random()+"").slice(2),window[k]=f[0],f[0]=k;else if("on"==b[0])"function"!=typeof f[f.length-1]&&f.push(()=>{}),f[f.length-1]={FUNC:E(f[f.length-1])};else if("off"==b[0])"function"==typeof f[f.length-1]&&(f[f.length-1]=f[f.length-1].__assocHndlrs||[]);else if("runInFrames"==b[0]&&(k=f[1],"object"==typeof k))for(let h in k)k[h]instanceof RegExp&&(k[h]={RE:k[h].source,F:k[h].flags});f=f.map(h=>"function"==typeof h?{FUNC:h+""}:h);v({type:"userAPI",scriptId:a,props:b,args:f,targetTabs:e,
trigInstId:c},h=>{if(h.error)A(h.error);else{let l=h.funcCode?FN(h.funcCode)(...h.args):h.result;h=Promise.resolve();if(l&&"object"==typeof l&&Symbol.iterator in l)for(let [t,q]of l.entries?l.entries():l)q&&q.funcCode&&q.args&&(l[t]=FN(q.funcCode)(...q.args),l[t]instanceof Promise&&(h=h.then(()=>l[t].then(F=>l[t]=F))));h.then(()=>D(l),A)}})});return z?n.then(...z):n}})}}function E(a){let g="_evt_"+(Math.random()+"").slice(2);a.__assocHndlrs||(a.__assocHndlrs=[]);a.__assocHndlrs.push(g);let e=new Promise(c=>
{window[g]=d=>{if("promise"==d)return e;c(d);a(d)}});return g}const m=chrome;Object.defineProperty(window,"FN",{value:a=>eval(`(${a})`)});const B=new Function("ACtl","funcCode","args","chrome","return eval('('+funcCode+')')( ...(args || []) )"),y=!m.runtime||!m.runtime.onMessage;if(y)window.addEventListener("message",a=>u(a.data,g=>parent.postMessage({pongId:a.data.pingId,result:g},"*")));else{let a=(c,d)=>{let b=location.ancestorOrigins.length;switch(c){case "depth":return b==d;case "mindepth":return b>=
d;case "maxdepth":return b<=d}},g=(c,d)=>d.RE?RegExp(d.RE,d.F).test(location[c]):location[c]==d,e=c=>{for(let d in c){let b=d.toLowerCase();if(!(b.endsWith("depth")?a:b in location?g:()=>!1)(b,c[d]))return!1}return!0};m.runtime.onMessage.addListener((c,d,b)=>{if(c.frmCBId)e(c.frmFlt)?u(c,w=>{v({pongId:c.frmCBId,result:w},()=>{})}):v({pongId:c.frmCBId,result:null},()=>{});else return u(c,b)})}let x={},r={};{let a={};window.runInPageCtx=(g,e)=>(c=()=>{})=>{void 0===e&&([g,e]=[e,g]);if(g){if(a[g])return c();
a[g]=!0}let d=document.createElement("script");"string"==typeof e?(d.src=e,d.onload=function(){this.remove();c({})},d.onerror=function(b){g&&delete a[g];this.remove();c({error:b.error||`Unable to load URL "${e}"`})},document.head.appendChild(d)):(d.textContent="function"==typeof e?`(${e})()`:e.code,document.head.appendChild(d),d.remove())}}})();
